package com.sc.server.system.auth.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import com.sc.server.system.auth.service.IRoleDeptService;
import com.sc.server.system.auth.entity.RoleDept;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
/**
 * <p>
 * 角色与部门对应关系 前端控制器
 * </p>
 *
 * @author zw
 * @since 2020-03-05
 */
@Api(description = "角色与部门对应关系 接口")
@RestController
@RequestMapping("/auth/roleDept")
public class RoleDeptController {
	@Autowired
	private IRoleDeptService roleDeptService;
/*	@PostMapping("page")
    @ApiOperation("获取数据列表")
	public PageEntity<RoleDept> findListByPage(@RequestBody BaseQueryVo<RoleDept> queryVo){
                     return roleDeptService.queryPage(queryVo);	}
	@ApiOperation("根据ID查找数据")
	@GetMapping("/{id}")
	public RoleDept find(@PathVariable("id") String id){
		RoleDept roleDept = roleDeptService.selectById(id);
			if(roleDept==null){
			throw new BusinessRuntimeException("查询不到此id的数据");
			}
			return roleDept;
	}

	@ApiOperation("添加数据")
	@PostMapping
	public RoleDept addItem(@RequestBody RoleDept roleDept){
			boolean isOk = roleDeptService.insert(roleDept);
			if(isOk){
			return roleDept;
			}
			throw new BusinessRuntimeException("新增失败！");
	}

	@ApiOperation("更新数据")
	@PutMapping
	public RoleDept updateItem(@RequestBody RoleDept roleDept){
		boolean isOk = roleDeptService.updateById(roleDept);
		if(isOk){
		return roleDept;
		}
		throw new BusinessRuntimeException("更新失败！");
	}

	@ApiOperation("删除数据")
	@DeleteMapping("{id}")
	public void deleteItem(@PathVariable("id") String id){
		boolean isOk = roleDeptService.deleteById(id);
		if(!isOk){
		throw new BusinessRuntimeException("数据删除失败");
		}
		}*/
	}
